# Contributor: Jakob Meier <comcloudway@ccw.icu>
# Maintainer: Jakob Meier <comcloudway@ccw.icu>
pkgname=carburetor
pkgver=4.5.1
pkgrel=0
pkgdesc="Graphical settings app for tractor in GTK"
url="https://framagit.org/tractor/carburetor"
# s390x: blocked by tractor which is blocked by tor
arch="noarch !s390x"
license="GPL-3.0-only"
depends="
	gtk4.0
	libadwaita
	tractor
	py3-gobject3
"
makedepends="gettext py3-gpep517 py3-setuptools py3-wheel py3-pytest"
subpackages="$pkgname-doc $pkgname-lang $pkgname-pyc"
source="https://framagit.org/tractor/carburetor/-/archive/$pkgver/carburetor-$pkgver.tar.gz"
# no tests available
options="!check"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

package() {
	python3 -m installer -d "$pkgdir" .dist/*.whl

	# generate translation files
	find po -iname '*.po' | \
		while read -r f; do
			lng="$(basename "$f" | cut -d'.' -f1)"
			mkdir -p "$pkgdir/usr/share/locale/$lng/LC_MESSAGES"
			msgfmt -o "$pkgdir/usr/share/locale/$lng/LC_MESSAGES/$pkgname.mo" "$f"
		done

	# Install man page
	install -Dm0644 -t "$pkgdir/usr/share/man/man1" data/carburetor.1

	# Install desktop integration files
	install -Dm0644 -t "$pkgdir/usr/share/applications" data/io.frama.tractor.carburetor.desktop
	install -Dm0644 -t "$pkgdir/usr/share/metainfo" data/metainfo/io.frama.tractor.carburetor.metainfo.xml

	# Install icons
	install -Dm644 data/icons/scalable/apps/io.frama.tractor.carburetor.svg -t "$pkgdir/usr/share/icons/hicolor/scalable/apps"
	install -Dm644 data/icons/symbolic/apps/io.frama.tractor.carburetor-symbolic.svg -t "$pkgdir/usr/share/icons/hicolor/symbolic/apps"
	mkdir -p "$pkgdir/usr/share/icons/hicolor/"
	cp -dpr data/icons/* "$pkgdir/usr/share/icons/hicolor/"
}

sha512sums="
e571670bfbfd315a29f93b18d929d7a449b620058b937c0090808e105e98ab00eef17cbe45fc465990dbc4f0b44e1fd1be4fac295ad6efb169eb3e53a3b68a40  carburetor-4.5.1.tar.gz
"
